﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
using KPIS.GERP.Models.BGM;
using KPIS.GERP.Models.Class;

namespace KPIS.GERP.Models.ICM
{
    [DataContract, Table("IcmAsset")]
    public class Asset
    {
        public Asset()
        {
            //AssetWarranties = new HashSet<AssetWarranty>();
            //RequestParcelDtls = new HashSet<RequestParcelDtl>();
            //Dispenses = new HashSet<Dispense>();
        }

        [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        [DataMember, Display(Name = "AssetId", ResourceType = typeof(Resources.AssetResource))]
        public int AssetId { get; set; }
        
        [CustomRequired]
        [StringLength(23)]
        [DataMember, Display(Name = "AssetCode", ResourceType = typeof(Resources.AssetResource))]
        public string AssetCode { get; set; }
        
        [ForeignKey("MasResourceItem")]
        [CustomRequired]
        [DataMember, Display(Name = "ResItemId", ResourceType = typeof(Resources.AssetResource))]
        public int ResItemId { get; set; }

        [CustomRequired]
        [DataMember, Display(Name = "AssetName", ResourceType = typeof(Resources.AssetResource))]
        public string AssetName { get; set; }

        [CustomRequired]
        [DataMember, Display(Name = "AssetDate", ResourceType = typeof(Resources.AssetResource))]
        public System.DateTime AssetDate { get; set; }

        [StringLength(50)]
        [CustomRequired]
        [DataMember, Display(Name = "SerialNumber", ResourceType = typeof(Resources.AssetResource))]
        public string SerialNumber { get; set; }

        [DataMember, Display(Name = "IsLowerAsset", ResourceType = typeof(Resources.AssetResource))]
        public bool IsLowerAsset { get; set; }

        [CustomRequired]
        [DataMember, Display(Name = "Quantity", ResourceType = typeof(Resources.AssetResource))]
        public int Quantity { get; set; }

        [DisplayFormat(DataFormatString = "{0:N4}")]
        [CustomRequired]
        [DataMember, Display(Name = "Price", ResourceType = typeof(Resources.AssetResource))]
        public double Price { get; set; }

        [ForeignKey("Warehouse")]
        [DataMember, Display(Name = "WhId", ResourceType = typeof(Resources.AssetResource))]
        public int WhId { get; set; }

        [ForeignKey("MasUnit")]
        [DataMember, Display(Name = "UnitId", ResourceType = typeof(Resources.AssetResource))]
        public int UnitId { get; set; }

        [ForeignKey("MasResourceType")]
        [DataMember, Display(Name = "AssetTypeId", ResourceType = typeof(Resources.AssetResource))]
        public Nullable<int> AssetTypeId { get; set; }

        [DataMember, Display(Name = "QualityAssuranceExpireDate", ResourceType = typeof(Resources.AssetResource))]
        public Nullable<System.DateTime> QualityAssuranceExpireDate { get; set; }

        [ForeignKey("MasBudgetSource")]
        [DataMember]
        public Nullable<int> BgSourceId { get; set; }

        [ForeignKey("ProjectExpense")]
        [DataMember, Display(Name = "ProjectId", ResourceType = typeof(Resources.AssetResource))]
        public Nullable<int> ProjExpId { get; set; }

        [ForeignKey("ReceiveDtl")]
        [DataMember, Display(Name = "ReceiveDtlId", ResourceType = typeof(Resources.AssetResource))]
        public int ReceiveDtlId { get; set; }

        [ForeignKey("MasResourceSubGroup")]
        [DataMember, Display(Name = "ResSubGrpId", ResourceType = typeof(Resources.AssetResource))]
        public int ResSubGrpId { get; set; }

        [ForeignKey("MasResourceGroup")]
        [DataMember, Display(Name = "ResGrpId", ResourceType = typeof(Resources.AssetResource))]
        public int ResGrpId { get; set; }

        [ForeignKey("AssetStatus")]
        [DataMember, Display(Name = "AssetStatusId", ResourceType = typeof(Resources.AssetResource))]
        public int AssetStatusId { get; set; }

        [ForeignKey("MasDepreciationType")]
        [DataMember, Display(Name = "DepreciationTypeId", ResourceType = typeof(Resources.AssetResource))]
        public Nullable<int> DepreciationTypeId { get; set; }

        [ForeignKey("JobSite")]
        [DataMember, Display(Name = "JobSiteId", ResourceType = typeof(Resources.AssetResource))]
        public Nullable<int> JobSiteId { get; set; }

        [DataMember, Display(Name = "Description", ResourceType = typeof(Resources.AssetResource))]
        public string Description { get; set; }

        [DataMember, Display(Name = "PicturePath", ResourceType = typeof(Resources.AssetResource))]
        public string PicturePath { get; set; }

        [DataMember, Display(Name = "Place", ResourceType = typeof(Resources.AssetResource))]
        public string Place { get; set; }

        [DataMember]
        public int? LifeYear { get; set; }

        [DataMember, Display(Name = "Remark", ResourceType = typeof(Resources.AssetResource))]
        public string Remark { get; set; }

        [StringLength(2)]
        [DataMember, Display(Name = "RecordStatus", ResourceType = typeof(Resources.AssetResource))]
        public string RecordStatus { get; set; }

        [DataMember, Display(Name = "CreatedBy", ResourceType = typeof(Resources.AssetResource))]
        public int CreatedBy { get; set; }

        [DataMember, Display(Name = "CreatedWhen", ResourceType = typeof(Resources.AssetResource))]
        public System.DateTime? CreatedWhen { get; set; }

        [DataMember, Display(Name = "UpdatedBy", ResourceType = typeof(Resources.AssetResource))]
        public Nullable<int> UpdatedBy { get; set; }

        [DataMember, Display(Name = "UpdatedWhen", ResourceType = typeof(Resources.AssetResource))]
        public Nullable<System.DateTime> UpdatedWhen { get; set; }

        [DataMember]
        public virtual ReceiveDtl ReceiveDtl { get; set; }

        [DataMember]
        public virtual ProjectExpense ProjectExpense { get; set; }

        [DataMember]
        public virtual MasResourceItem MasResourceItem { get; set; }

        [DataMember]
        public virtual MasResourceType MasResourceType { get; set; }

        [DataMember]
        public virtual Warehouse Warehouse { get; set; }

        [DataMember]
        public virtual MasUnit MasUnit { get; set; }

        [DataMember]
        public virtual MasResourceSubGroup MasResourceSubGroup { get; set; }

        [DataMember]
        public virtual MasResourceGroup MasResourceGroup { get; set; }

        [DataMember]
        public virtual IcmMasLookUp AssetStatus { get; set; }

        [DataMember]
        public virtual HRM.JobSite JobSite { get; set; }

        [DataMember]
        public virtual MasDepreciationType MasDepreciationType { get; set; }

        [DataMember]
        public virtual MasBudgetSource MasBudgetSource { get; set; }
        //[DataMember]
        //public virtual ICollection<AssetWarranty> AssetWarranties { get; set; }

        //[DataMember]
        //public virtual ICollection<RequestParcelDtl> RequestParcelDtls { get; set; }

        //[DataMember]
        //public virtual ICollection<Dispense> Dispenses { get; set; }
    
    }
}
